// 引入路由
import ShengXian from '../views/homepage/ShengXian.vue';
import TiaoLiao from '../views/homepage/TiaoLiao.vue';
import ShengRou from '../views/homepage/shengxian/ShengRou.vue'
import DanLei from '../views/homepage/shengxian/DanLei.vue';
// import NotFound from '../views/NotFound.vue';
const NotFound = ()=>import('../views/NotFound.vue')
const routes = [
    {
        path:'/homepage',//此处/代表根路径  路径当中不建议有中文
        name:'homepage',
        component:()=>import('../views/HomePage.vue'),
        meta:{
            show:true
        },
        beforeEnter: (to, from, next) => {
            // ...
            console.log(to);
            console.log(from);
            console.log(next);
            next();
        },
        children:[
            {
                path:'shengxian',
                name:'shengxian',
                component:ShengXian,
                children:[
                    {
                        path:'shengrou',//可以省略父级的路径，直接写当前的，但是不能在前面加 / 
                        name:'shengrou',
                        component:ShengRou
                    },
                    {
                        path:'/homepage/shengxian/danlei',
                        name:'danlei',
                        component:DanLei
                    }
                ]
            },{
                path:'/homepage/tiaoliao',
                name:'tiaoliao',
                component:TiaoLiao
            }
        ]
    },
    {
        path:'/catepage',
        name:'catepage',
        component:()=>import('../views/CatePage.vue'),
        meta:{
            show:true
        },
    },
    {
        path:"/cartpage",
        name:'cartpage',
        component:()=>import('../views/CartPage.vue'),
        meta:{
            show:true
        },
        children:[
            {
                path:'goodslist',
                name:'goodslist',
                component:()=>import('@/views/cartpage/GoodsList.vue')
            },
            {
                path:'jiesuan',
                name:'jiesuan',
                component:()=>import('@/views/cartpage/JieSuan.vue')
            }
        ]

    },
    {
        path:'/personalpage',
        name:'personalpage',
        // alias:'/hanhan',//别名
        component:()=>import('../views/PersonalPage.vue'),
        meta:{
            show:true
        },
        children:[
            {
                path:'shezhi',
                name:'shezhi',
               /*  component:()=>import('../views/personalpage/SheZhi.vue') */
               components:{
                   default:()=>import('../views/personalpage/SheZhi.vue'),
                   one:()=>import('../views/personalpage/SheZhiOne.vue'),
                   two:()=>import('../views/personalpage/SheZhiTwo.vue')
               }
            },
            {
                path:'geren',
                name:'geren',
                component:()=>import('../views/personalpage/GeRen.vue')
            }
        ]
    },
    // goods详情
    {
        // params传值 一定要先配置占位符
        path:'/goodsitem',
        name:'goodsitem',
        component:()=>import('../views/GoodsItem.vue')
    },
    {
        path:'/register',
        name:'register',
        component:()=>import('../views/Register.vue')
    },
    {
        path:'/login',
        name:'login',
        component:()=>import('../views/Login.vue') 
    },
    {
        path:'/vip',
        name:'vip',
        component:()=>import('../views/vip.vue')
    },
    // 重定向
    {
        path:'/',
        // redirect:'/homepage'
        redirect:{
            // name:'homepage'
            path:'/homepage'
        }
    },
    // *所有不存在
    {
        path:'*',
        component:NotFound
    }
]


/* 
路由守卫 三类
路由全局守卫
前置 router.beforeEach
后置 router.afterEach

组件守卫
beforeRouteEnter
beforeRouteLeave
beforeRouteUpdate

单独路由独享守卫
beforeEnter



*/
export default routes;